import { createApp } from 'vue'
import App from './App.vue'

// 引入全局样式表
import './assets/css/global.less'

// 引入element-plugs字体图标
import * as Icons from '@element-plus/icons-vue';
// element-plus 样式表
import 'element-plus/dist/index.css' 

// 引入axios
import axios from 'axios'
import VueAxios from 'vue-axios';
axios.defaults.baseURL = '/api';
// axios.defaults.withCredentials = true; // 在请求之前携带cookie

const app = createApp(App);
// 遍历element-plugs字体图标并注册为组件
Object.keys(Icons).forEach(key => {
    app.component(key, Icons[key])
})

// 引入vuex
import store from './store/index'
app.use(store);

// app.use(ElementPlus)
app.use(VueAxios, axios);
app.config.globalProperties.$axios = axios;

// 全局事件总线
import mitt from 'mitt';
const emitter = mitt();
app.provide('emitter', emitter);  //全局事件总线

// 路由
import router from './router/index'
app.use(router);

// 定义全局组件
import UserFooter from './components/header/user/header_bottom/UserFooter.vue';
import Loading from './components/globalCompoents/Loading.vue';
import Fun from './components/globalCompoents/Fun.vue';
app.component('UserFooter', UserFooter);
app.component('loading', Loading);
app.component('Fun', Fun);

app.mount('#app');